all:
	make english
	sleep .1 ; cd en ; make
	make espanol
	sleep .1 ; cd es ; make
	make esperanto
	sleep .1 ; cd eo ; make

esperanto:
	sh eo.sh && mkdir $$(cat lists/mkdir.txt | sed 's^%l^eo^g')
	while read file ;  do \
		. ./eo.sh ; \
		envsubst < "$$file" > "$$(echo $$file | sed 's/meta/md/' | sed 's^pages^eo/lgn^')" ; \
		done < lists/md.txt
	cp swx/* eo/
	cp -r misc/res eo/lgn/res
	sleep .1 ; . ./eo.sh ; envsubst < misc/swx.conf.meta > eo/swx.conf
	sleep .1 ; . ./eo.sh ; envsubst < misc/Makefile.meta > eo/Makefile
	sleep .1 ; . ./eo.sh ; envsubst < misc/res/js/utctime.js.meta > eo/lgn/res/js/utctime.js
	mv eo/lgn/index.md eo/lgn/indekso.md
	mv eo/lgn/contact.md eo/lgn/kontakti.md
	mv eo/lgn/list.md eo/lgn/listo.md
	mv eo/lgn/schedule.md eo/lgn/tempoplano.md

english:
	sh en.sh && mkdir $$(cat lists/mkdir.txt | sed 's^%l^en^g')
	while read file ;  do \
		. ./en.sh ; \
		envsubst < "$$file" > "$$(echo $$file | sed 's/meta/md/' | sed 's^pages^en/lgn^')" ; \
		done < lists/md.txt
	cp swx/* en
	cp -r misc/res en/lgn/res
	sleep .1 ; . ./en.sh ; envsubst < misc/swx.conf.meta > en/swx.conf
	sleep .1 ; . ./en.sh ; envsubst < misc/Makefile.meta > en/Makefile
	sleep .1 ; . ./en.sh ; envsubst < misc/res/js/utctime.js.meta > en/lgn/res/js/utctime.js

espanol:
	sh es.sh && mkdir $$(cat lists/mkdir.txt| sed 's^%l^es^g')
	while read file ;  do \
		. ./es.sh ; \
		envsubst < "$$file" > "$$(echo $$file | sed 's/meta/md/' | sed 's^pages^es/lgn^')" ; \
		done < lists/md.txt
	cp -r misc/res es/lgn/res
	sleep .1 ; . ./es.sh ; envsubst < misc/swx.conf.meta > es/swx.conf
	sleep .1 ; . ./es.sh ; envsubst < misc/Makefile.meta > es/Makefile
	sleep .1 ; . ./es.sh ; envsubst < misc/res/js/utctime.js.meta > es/lgn/res/js/utctime.js
	cp swx/* es
	mv es/lgn/index.md es/lgn/índice.md
	mv es/lgn/contact.md es/lgn/contacto.md
	mv es/lgn/list.md es/lgn/lista.md
	mv es/lgn/schedule.md es/lgn/programa.md

clean:
	rm -rf en/ es/ eo/
